import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class ButtonServePerson extends JButton
{

	private Store _store;
	private int _queueNr;
	private JFrame parent;

	public ButtonServePerson(Store _store, JList _lstCustomersInQueue, int _queueNr, JFrame parent)
	{
		super("Serve");
		this._store = _store;
		this.parent = parent;
		this.addActionListener(new Listener());
		this._queueNr = _queueNr;
	}
	
	private class Listener implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			if(!_store.getQueues()[_queueNr].isEmpty())
			{
				CartinfoDialog tmp = new CartinfoDialog(parent, _store.getQueues()[_queueNr].dequeuePerson());
				tmp.setVisible(true);
			}
		}
	}
}
